package com.zzs.server.dao.mysql;

import com.zzs.common.core.entity.mysql.TestCaseDO;
import org.apache.ibatis.annotations.*;

/**
 * @author zzs
 * @date 2025/03/18
 */
@Mapper
public interface TestCaseMapper {
    @Insert("insert into test_case (id, problem_id, test_case, create_time, update_time) values (#{id}, #{problemId}, #{testCase}, #{createTime}, #{updateTime})")
    int save(TestCaseDO testCaseDO);

    @Update("update test_case set test_case = #{testCase}, update_time = #{updateTime} where problem_id = #{problemId}")
    int update(TestCaseDO testCaseDO);

    @Select("select problem_id, test_case from test_case where problem_id = #{problemId}")
    TestCaseDO get(@Param("problemId") long problemId);

    @Delete("delete from test_case where problem_id = #{problemId}")
    int remove(@Param("problemId") long problemId);

    @Delete("delete from test_case where problem_id = #{problemId}")
    void removeByProblemId(@Param("problemId") long problemId);

    @Select("select exists(select 1 from test_case where problem_id = #{problemId})")
    boolean existsByProblemId(@Param("problemId") long problemId);
}
